- Article
- 2018-12-23
Автор статьи: Mort3m
Вообще, сама задумка статьи с зм сру, но так как это мертвый сайт, кого это волнует?
В данной статье я вам расскажу как можно добавить собственные ( кастомные ) модели игрокам.
Многие делают эти самые модели через мод, как по мне, легче сделать так, как я опишу в этом гайде.
И так, для начала нам нужен Zombie Plague Fix5a. Потому что в этом фиксе есть натив на установку кастомной модели.
Если данного фикса у вас на моде нету, берём обычный Zombie Plague.
ВНИМАНИЕ! Следующий блок статьи пойдет о том, как добавить натив на установку кастомной модели. Т.е для тех, у кого нет Fix5a.
Приступим.
1. Открываем исходник мода.
2. Ищем строку
public plugin_natives()
3. Ищем свободное место для добавления натива. Либо место, куда вы бы хотели поместить сам натив.
Лично я это буду делать после натива zp_force_buy_extra_item
Добавляем строку:
register_native("zp_override_user_model", "native_override_user_model", 1);
Должно получиться так:
![](/uploads/posts/2018-12/thumbs/screenshot_13.png)
Спускаемся до строки:
/*================================================================================
[Custom Natives]
=================================================================================*/
И в любом удобном месте вставляем этот блок кода:
// Native: zp_override_user_model
public native_override_user_model(id, const newmodel[], modelindex)
{
// ZP disabled
if (!g_pluginenabled)
return false;
if (!is_user_valid_connected(id))
{
log_error(AMX_ERR_NATIVE, "[ZP] Invalid Player (%d)", id)
return false;
}
// Strings passed byref
param_convert(2)
// Remove previous tasks
remove_task(id+TASK_MODEL)
// Custom models stuff
static currentmodel[32]
if (g_handle_models_on_separate_ent)
{
// Set the right model
copy(g_playermodel[id], charsmax(g_playermodel[]), newmodel)
if (g_set_modelindex_offset && modelindex) fm_cs_set_user_model_index(id, modelindex)
// Set model on player model entity
fm_set_playermodel_ent(id)
}
else
{
// Get current model for comparing it with the current one
fm_cs_get_user_model(id, currentmodel, charsmax(currentmodel))
// Set the right model, after checking that we don't already have it
if (!equal(currentmodel, newmodel))
{
copy(g_playermodel[id], charsmax(g_playermodel[]), newmodel)
if (g_set_modelindex_offset && modelindex) fm_cs_set_user_model_index(id, modelindex)
// An additional delay is offset at round start
// since SVC_BAD is more likely to be triggered there
if (g_newround)
set_task(5.0 * g_modelchange_delay, "fm_user_model_update", id+TASK_MODEL)
else
fm_user_model_update(id+TASK_MODEL)
}
}
return true;
}
Должно получиться так: ( Шрифт уменьшил чтобы код влез полностью )
![](/uploads/posts/2018-12/thumbs/screenshot_16.png)
Если вы всё сделали правильно, компиляция должна пройти успешно:
![](/uploads/posts/2018-12/thumbs/screenshot_15.png)
ВНИМАНИЕ! Следующий блок статьи пойдет для всех пользователей, имеющих как обычный Zombie Plague так и Fix5a.
Итак, перейдем к основному.
Теперь нам надо будет написать маленький плагин, добавляющий вашу модель игрокам. Сам плагин я выложу в этой статье.
1. Создаём файл формата .sma с любым угодным вам названием
2. Заходим в файл любым текстовым редактором.
3. Подключаем инклуды + Оффсеты.
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
// Оффсеты
#define linux_diff_player 5
#define m_modelIndexPlayer 491
4. Вписываем натив + некоторые макросы + создаём переменную.
Важно! ПАПКА С МОДЕЛЬЮ И САМА МОДЕЛЬ ДОЛЖНЫ БЫТЬ С ОДИНАКОВЫМИ НАЗВАНИЯМИ
// Сам натив
native zp_override_user_model(pPlayer, szModel[], iModelIndex = 0);
#define MODEL_NAME "tommy" // Название модели
#define MODEL_PATH "models/player/%s/%s.mdl" // Оригинальный путь до моделей.
#define MODEL_ACCESS_ADMIN ADMIN_BAN // Установка модели только Админу. Закомментируйте, если не нужно
// Создаём переменную для хранения в ней индекса модели
new g_iszModelIndex;
5. Теперь нам надо вписать два форварда. plugin_precache и plugin_init
И в них зарегистрировать нужное нам событие и регистрацию плагина ( по желанию )
// Прекеш модели
public plugin_precache()
{
static szModelPath[128];
formatex(szModelPath, charsmax(szModelPath), MODEL_PATH, MODEL_NAME, MODEL_NAME);
// Присваиваем индекс модели переменной
g_iszModelIndex = engfunc(EngFunc_PrecacheModel, szModelPath);
}
// Регистрация нужных нам событий ( register_plugin по желанию )
public plugin_init()
{
// Регистрируем плагин
register_plugin("[AMXX] Custom Model", "0.0.1", "m0rt3m/тут может быть ваш ник");
// Ловим эвент спавна игрока
RegisterHam(Ham_Spawn, "player", "HamHook__PlayerSpawn_Post", 1);
}
6. Теперь нам осталось создать публичную функцию и вписать форвард когда игрок превращается в человека.
public HamHook__PlayerSpawn_Post(iPlayer)
{
// Проверяем на коннект
if(!is_user_connected(iPlayer))
return;
// Проверяем на зомби и выжившего
if(zp_get_user_zombie(iPlayer) || zp_get_user_survivor(iPlayer))
return;
// Проверяем на наличие флага, если макрос не закомментирован
#if defined MODEL_ACCESS_ADMIN
if(~get_user_flags(iPlayer) & MODEL_ACCESS_ADMIN)
return;
#endif
// Выставляем модель
zp_override_user_model(iPlayer, MODEL_NAME, g_iszModelIndex);
// Выставляем нужный индекс модели, чтобы не слетал
set_pdata_int(iPlayer, m_modelIndexPlayer, g_iszModelIndex, linux_diff_player);
}
public zp_user_humanized_post(iPlayer, iSurvivor)
{
// Проверяем на выжившего
if(iSurvivor)
return;
// Проверяем на наличие флага, если макрос не закомментирован
#if defined MODEL_ACCESS_ADMIN
if(~get_user_flags(iPlayer) & MODEL_ACCESS_ADMIN)
return;
#endif
// Выставляем модель
zp_override_user_model(iPlayer, MODEL_NAME, g_iszModelIndex);
// Выставляем нужный индекс модели, чтобы не слетал
set_pdata_int(iPlayer, m_modelIndexPlayer, g_iszModelIndex, linux_diff_player);
}
Плагин можно довести до ума, и сделать выставление моделей по ини и т.д, собственно, если вы шарите в павне, для вас это не будет особой проблемой.
Donate you can do to the author Mort3m, a gift in the form of a donation to his electronic piggy bank ;)
%25
Discount on all purchases
builds until September 16, 2024
Especially for you - Гость
![](https://vk.com/images/emoji/2764_2x.png)
Buy an assembly
![](http://www.tb-team.com/uploads/fotos/foto_9428.jpg)
[CS 1.6] Weapon Model - Ethereal Xmas
one of the best p90 models, we had on the server. ++
![](http://www.tb-team.com/uploads/fotos/foto_9979.jpg)
[CS 1.6] Knife Model - Xmas Candy Axe
nice xmas model
![](http://www.tb-team.com/uploads/fotos/foto_9979.jpg)
[CS 1.6] Weapon Model - White Railcannon Xmas
Nice model thanks
![](http://www.tb-team.com/uploads/fotos/foto_9979.jpg)
[CS 1.6] Weapon Model - Royale Dragon M4a1
Nice model thanks
![](http://tb-team.com/uploads/fotos/foto_1.png)
[ZP] Zombie Class - Revenant Raving (Переделка Fire)
happy to hear that from you ! enjoy
ReHLDS (Reverse-engineered) - this is a new step forward that gives a second wind to our servers. ReHLDS works 2 times faster than HLDS.
AMXModX is a Metamod add-on that allows you to create new modifications for Half-Life in the Pawn language
Reunion is a continuation of Dproto for ReHLDS. This is a metamod plugin that allows you to log into the 47/48 Non-Steam server.
Revoice is a Metamod plugin that allows voice chat between non-steam and steam clients.
The new Metamod-r contains a huge number of performance optimizations and much cleaner code. The kernel was written using a JIT compiler.
Ultimate Unprecacher is a plugin for MetaMod, it works on the principle of disabling unnecessary resources on your server, thereby you can free up space for resources for your plugins, using this module you can get rid of error 512!
ReAuthCheck - this is a Metamod plugin that checks your players for validity, with this module for REHLDS you can protect your server from bots that constantly spam ads or simply clog up a slot on the server!
NetBufExtender or NBEX - This is a metamod plugin that expands the пїЅInternet bufferпїЅ: server and client buffers (not 100% guaranteed). Expands up to 64 kb. This means that players are less likely to be kicked with the error "Reliable channel overflowed"".
UINO пїЅ metamod plugin that allows you to remove unnecessary fields from userinfo(setinfo) when the engine passes it to other players on the server. This measure reduces the amount of data transferred and slightly reduces the chance of being kicked with "Reliable channel overflowed".